(function(){var e=window.BX;e.namespace("BX.UI");if(!!e.UI.Selector.Navigation){return}e.UI.Selector.Navigation=function(e){this.keys={enter:13,space:32,left:37,up:38,right:39,down:40};this.selectorInstance=e.selectorInstance;this.selectorManager=this.selectorInstance.manager};e.UI.Selector.Navigation.create=function(t){return new e.UI.Selector.Navigation(t)};e.UI.Selector.Navigation.prototype.checkKeyboardNavigation=function(e){var t=e.keyCode?e.keyCode:false,s=e.tab?e.tab:false;if(t==this.keys.left){this.moveCurrentItem({tab:s,direction:"left"});return"move"}else if(t==this.keys.up){this.moveCurrentItem({tab:s,direction:"up"});return"move"}else if(t==this.keys.right){this.moveCurrentItem({tab:s,direction:"right"});return"move"}else if(t==this.keys.down){this.moveCurrentItem({tab:s,direction:"down"});return"move"}else if(t==this.keys.enter){this.selectCurrentItem({tab:s,keyCode:t});return"enter"}else if(t==this.keys.space&&s!="search"){if(this.selectorInstance.id.match(/^mention/i)){this.selectorInstance.closeDialog();return false}else{this.selectCurrentItem({tab:s,keyCode:t});return"space"}}return false};e.UI.Selector.Navigation.prototype.selectCurrentItem=function(t){var s=t.tab,o=typeof t.keyCode!="undefined"&&t.keyCode==this.keys.enter;if(!this.selectorInstance.popups.search&&!this.selectorInstance.popups.main&&!this.selectorInstance.popups.container){return}if(s=="search"){clearTimeout(this.selectorInstance.timeouts.search);this.selectorInstance.getSearchInstance().abortSearchRequest()}var n=this.selectorInstance.cursors[s].currentItem;if(e.type.isNotEmptyObject(n)){var r=this.selectorInstance.getItemNodeId({entityType:n.entityType,itemId:n.itemCode});if(e(r)){this.selectorInstance.selectItem({entityType:e(r).getAttribute("data-entity-type"),itemNode:e(r),itemId:n.itemCode,tab:s})}}if(o&&this.selectorInstance.cursors[s]){this.selectorInstance.cursors[s].currentItem=null;if(this.selectorInstance.isDialogOpen()){this.selectorInstance.closeDialog()}this.selectorInstance.closeSearch()}};e.UI.Selector.Navigation.prototype.selectFirstItem=function(t){var s=t.tab;if(!this.selectorInstance.popups.search&&!this.selectorInstance.popups.main&&!this.selectorInstance.popups.container){return}if(s=="search"){clearTimeout(this.selectorInstance.timeouts.search);this.selectorInstance.getSearchInstance().abortSearchRequest()}var o=this.selectorInstance.cursors[s].firstItem;if(e.type.isNotEmptyObject(o)){var n=this.selectorInstance.getItemNodeId({entityType:o.entityType,itemId:o.itemCode});if(e(n)){this.selectorInstance.selectItem({entityType:e(n).getAttribute("data-entity-type"),itemNode:e(n),itemId:o.itemCode})}}};e.UI.Selector.Navigation.prototype.moveCurrentItem=function(t){var s=t.direction,o=t.tab;if(!s){return}if(this.selectorInstance.popups.search==null&&this.selectorInstance.popups.main==null&&this.selectorInstance.popups.container==null){return}this.selectorInstance.resultChanged[o]=true;if(o=="search"&&this.selectorInstance.searchXhr){this.selectorInstance.getSearchInstance().abortSearchRequest();this.selectorInstance.getSearchInstance().hideSearchWaiter()}if(!e.type.isNotEmptyObject(this.selectorInstance.cursors[o])){return}var n=false;switch(s){case"left":if(this.selectorInstance.cursors[o].position.column==1){if(typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row][this.selectorInstance.cursors[o].position.column-1]!="undefined"){this.selectorInstance.cursors[o].position.column--;n=true}}break;case"right":if(this.selectorInstance.cursors[o].position.column==0&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row][this.selectorInstance.cursors[o].position.column+1]!="undefined"){this.selectorInstance.cursors[o].position.column++;n=true}break;case"up":if(this.selectorInstance.cursors[o].position.row>0&&typeof this.selectorInstance.result[o]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row-1]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row-1][this.selectorInstance.cursors[o].position.column]!="undefined"){this.selectorInstance.cursors[o].position.row--;n=true}else if(this.selectorInstance.cursors[o].position.row==0&&typeof this.selectorInstance.result[o]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group-1]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group-1][this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group-1].length-1]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group-1][this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group-1].length-1][0]!="undefined"){this.selectorInstance.cursors[o].position.row=this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group-1].length-1;this.selectorInstance.cursors[o].position.column=0;this.selectorInstance.cursors[o].position.group--;n=true}break;case"down":if(typeof this.selectorInstance.result[o]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row+1]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row+1][this.selectorInstance.cursors[o].position.column]!="undefined"){this.selectorInstance.cursors[o].position.row++;n=true}else if(typeof this.selectorInstance.result[o]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row+1]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row+1][0]!="undefined"){this.selectorInstance.cursors[o].position.column=0;this.selectorInstance.cursors[o].position.row++;n=true}else if(typeof this.selectorInstance.result[o]!="undefined"&&this.selectorInstance.cursors[o].position.row==this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group].length-1&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group+1]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group+1][0]!="undefined"&&typeof this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group+1][0][0]!="undefined"){this.selectorInstance.cursors[o].position.group++;this.selectorInstance.cursors[o].position.row=0;this.selectorInstance.cursors[o].position.column=0;n=true}break;default:}if(n){var r=this.selectorInstance.cursors[o].currentItem;var c=this.selectorInstance.getItemNodeId({entityType:r.entityType,itemId:r.itemCode});if(e(c)){this.selectorInstance.getRenderInstance().unhoverItem({node:e(c)})}r=this.selectorInstance.result[o][this.selectorInstance.cursors[o].position.group][this.selectorInstance.cursors[o].position.row][this.selectorInstance.cursors[o].position.column];this.selectorInstance.cursors[o].currentItem=r;c=this.selectorInstance.getItemNodeId({entityType:r.entityType,itemId:r.itemCode});if(e(c)){var i=0,a=e(c);var l=e.findParent(this.selectorInstance.dialogNodes.contentsContainer,{className:this.selectorInstance.getRenderInstance().class.boxContainer});if(l){var u=e.pos(l),I=e.pos(a);if(I.bottom>u.bottom||I.top<u.top){l.scrollTop+=I.bottom>u.bottom?I.bottom-u.bottom:I.top-u.top}this.selectorInstance.getRenderInstance().hoverItem({node:a})}}}};e.UI.Selector.Navigation.prototype.hoverFirstItem=function(t){var s=t.tab;if(typeof this.selectorInstance.cursors[s]=="undefined"){return}var o=this.selectorInstance.cursors[s].firstItem;if(!o){return}var n=this.selectorInstance.getItemNodeId({entityType:o.entityType,itemId:o.itemCode});if(!e(n)){return}this.selectorInstance.getRenderInstance().hoverItem({node:e(n)})}})();
//# sourceMappingURL=navigation.map.js